package com.mad.base.manager;

import java.util.ArrayList;

import com.mad.base.objects.GameObject;
import com.mad.base.objects.ships.EShipType;
import com.mad.base.objects.ships.Ship;
import com.mad.base.system.EDirection;
import com.mad.base.system.ID;

public class ShipManager
    extends SubManager
{

    private ArrayList<Ship> ships;

    public Ship getShipByID( ID fieldID )
    {
        for ( Ship s : ships )
            if ( s.isHit( fieldID ) )
                return s;
        return null;
    }

    public ShipManager( Manager parentManager )
    {
        super( parentManager );
    }

    @Override
    public void init( Object o )
    {
        this.ships = new ArrayList<Ship>();
    }

    @Override
    public void exit( Object o )
    {

    }

    @Override
    public void update( Object o )
    {

    }

    protected void spawnShip( EShipType shipType, ID bowID, EDirection dir )
    {
        this.ships.add( new Ship( shipType, bowID, dir ) );
    }

}
